/*
$().ready(function() {
	validateRule();
});
*/




$(function() {
	validateRule();
	//打开图标列表
    $("#ico-btn").click(function(){
        layer.open({
            type: 2,
			title:'图标列表',
            content: '../../../public/FontIcoList.html',
            area: ['480px', '90%'],
            success: function(layero, index){
                //var body = layer.getChildFrame('.ico-list', index);
               // console.log(layero, index);
            }
        });
    });
});
$.validator.setDefaults({
	submitHandler : function() {
		submit01();
	}
});
function submit01() {
var check = document.getElementsByTagName('input')[0];
var parentId = check.value;
if(parentId == ''){
    $('#parentId').val('0');
}
	$.ajax({
		cache : true,
        		type : "POST",
        		headers:{"JwtAuthorization":JwtAuthorizations,"Authorization":token},
        		url : API_SERVER_URL + "aipark/area/save",
        		data : $('#signupForm').serialize(),// 你的formid
        		async : false,
        		error : function(request) {
        			parent.layer.alert("Connection error");
        		},
		success : function(data) {
			if (data.code == 0) {
				parent.layer.msg("保存成功");
				window.parent.location.reload() ;
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);

			} else {
				layer.alert(data.msg)
			}
		}
	});
}

function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
        			name : {
        				required : true
        			},
        			code : {
                        required : true,
                        digits : true
                    }
        		},
        		messages : {
        			name : {
        				required : icon + "请输入区域名称"
        			},
        			code : {
                        required : icon + "请输入编号",
                        digits:icon + "请输入整数数字",
                    }
        		}
	})
}